package com.example.syyao.myapp.Sign;

import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import com.example.syyao.myapp.MainActivity;
import com.example.syyao.myapp.R;

public class WelcomeActivity extends AppCompatActivity {

    Button sign_in;
    Button sign_up;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.welcome);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);
        }
        sign_up=findViewById(R.id.sign_up);
        sign_in=findViewById(R.id.sign_in);

        sign_up.setOnClickListener(new sign_up_click());
        sign_in.setOnClickListener(new sign_in_click());

        SharedPreferences sharedPreferences=getSharedPreferences(MainActivity.PREFERENCE_NAME,MainActivity.MODE);
        SharedPreferences.Editor editor=sharedPreferences.edit();
        editor.putBoolean("isFirst",false);
        editor.apply();
    }

    private class sign_up_click implements View.OnClickListener {
        @Override
        public void onClick(View v) {
            Intent intent=new Intent();
            intent.setClass(WelcomeActivity.this, Sign_up.class);
            startActivity(intent);
            finish();
        }
    }

    private class sign_in_click implements View.OnClickListener {
        @Override
        public void onClick(View v) {
            Intent intent=new Intent();
            intent.setClass(WelcomeActivity.this, Sign_in.class);
            startActivity(intent);
            finish();
        }
    }
}
